﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Data;

namespace Mengoo.BDMTier
{
    public interface IDAO
    {
        #region 基础方法 执行简单SQL

        #region Insert
        /// <summary>
        /// 添加一条记录
        /// </summary>
        /// <param name="model">记录实体</param>
        /// <returns></returns>
        int Add(object model);

        /// <summary>
        /// 添加一条记录
        /// </summary>
        /// <param name="model">记录实体</param>
        /// <param name="exceptColumns">不需要插入的列，用，分隔</param>
        /// <returns></returns>
        int Add(object model, string exceptColumns);

        /// <summary>
        /// 添加多条记录
        /// </summary>
        /// <param name="modelList">记录集合</param>
        /// <returns></returns>
        int Add(List<object> modelList);

        /// <summary>
        /// 添加多条记录
        /// </summary>
        /// <param name="modelList">记录集合</param>
        /// <param name="exceptColumns">不需要插入的列，用，分隔</param>
        /// <returns></returns>
        int Add(List<object> modelList, string exceptColumns);

        /// <summary>
        /// 添加一条记录
        /// </summary>
        /// <param name="columns">列的键值对</param>
        /// <returns></returns>
        int Add(Hashtable columns);
        
        /// <summary>
        /// 添加多条记录
        /// </summary>
        /// <param name="columnsList">列的键值对</param>
        /// <returns></returns>
        int Add(List<Hashtable> columnsList);
        #endregion

        #region Delete
        /// <summary>
        /// 删除记录，根据条件
        /// </summary>
        /// <param name="where">删除条件</param>
        /// <returns></returns>
        int Del(string where);

        /// <summary>
        /// 删除记录，根据记录实体
        /// </summary>
        /// <param name="model">记录实体</param>
        /// <returns></returns>
        int Del(object model);

        /// <summary>
        /// 删除记录，根据记录实体
        /// </summary>
        /// <param name="model">记录实体</param>
        /// <param name="keyField">关键字段名称</param>
        /// <returns></returns>
        int Del(object model, string keyField);

        /// <summary>
        /// 删除记录集合
        /// </summary>
        /// <param name="modelList">要删除的实体记录集合</param>
        /// <returns></returns>
        int Del(List<object> modelList);

        /// <summary>
        /// 删除记录集合
        /// </summary>
        /// <param name="modelList">要删除的实体记录集合</param>
        /// <param name="keyField">记录的关键字段名称</param>
        /// <returns></returns>
        int Del(List<object> modelList, string keyField);
        #endregion

        #region Update
        /// <summary>
        /// 更新记录，根据实体和默认的关键字段名称
        /// </summary>
        /// <param name="model">数据实体</param>
        /// <returns></returns>
        int Update(object model);

        /// <summary>
        /// 更新记录，根据实体和关键字段名称
        /// </summary>
        /// <param name="model">数据实体</param>
        /// <param name="keyField">关键字字段</param>
        /// <returns></returns>
        int Update(object model, string keyField);

        /// <summary>
        /// 更新记录，根据列的键值对
        /// </summary>
        /// <param name="columns">列的键值对</param>
        /// <param name="where">更新条件</param>
        /// <returns></returns>
        int Update(Hashtable columns, string where);
        #endregion

        #region Select
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        DataTable GetTableList();

        /// <summary>
        /// 获取列表，根据查询条件
        /// </summary>
        /// <param name="where">查询条件</param>
        /// <returns></returns>
        DataTable GetTableList(string where);
        /// <summary>
        /// 获取列表，根据查询条件，指定表名
        /// </summary>
        /// <param name="columns">要查询的列</param>
        /// <param name="where">查询条件</param>
        /// <returns></returns>
        DataTable GetTableList(string columns, string where);
        #endregion

        #endregion

        #region 基础方法，执行存储过程
        int AddByStoreProcess(object model);

        int DelByStoreProcess();

        int UpdateByStoreProcess();

        DataTable GetTableListByStoreProcess();
        #endregion
    }
}
